package com.atming.zuul.controller;


import com.atming.zuul.pojo.Product;
import com.atming.zuul.service.ProductService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Resource
    private ProductService productService;


    /**
     * 根据主键查询商品
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Product selectProductById(@PathVariable("id") Long id) throws InterruptedException {
       // TimeUnit.SECONDS.sleep(2); //模拟超时2s

        return productService.selectPrdductById(id);
    }



    /**
     * 根据主键查询商品
     * @param id
     * @return
     */
    @GetMapping("/single")
    public Product selectProductBySingleId( Long id){
        return productService.selectPrdductById(id);
    }





}
